package github.kawaiior.yuanchuxiuzhen.common.item.test;

import github.kawaiior.yuanchuxiuzhen.common.capability.entity.ManaPower;
import github.kawaiior.yuanchuxiuzhen.core.init.itemgroup.YcxzGroup;
import github.kawaiior.yuanchuxiuzhen.core.registry.ModCapability;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.world.World;
import net.minecraftforge.common.util.LazyOptional;

public class ManaRootAll extends Item {
    public ManaRootAll() {
        super(new Properties().group(YcxzGroup.YCXZ_GROUP));
    }

    @Override
    public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand hand) {
        LazyOptional<ManaPower> capability = player.getCapability(ModCapability.MANA_POWER);
        capability.ifPresent((power)->{
           byte[] bytes = power.getManaRootArray();
            for (int i = 0; i < bytes.length; i++) {
                bytes[i] = 1;
            }
        });
        return super.onItemRightClick(world, player, hand);
    }
}
